import server  from '../server'

var getNav = function() {
    return new Promise((resolve,reject) => {
        server.get('/json/fenlei.json').then(res => {
            resolve(res)
        })
    })
}

var  getlist = function(id) {
    return new Promise((resolve,reject) => {
        server.get('/json/list.json').then(res => {
            // resolve(res)
            console.log(id);
            
            var list = res.data.result
            var arr = []
            list.forEach(item => {
                if(item.cid == id){
                    arr.push(item)
                }
            });
            resolve( arr)
        })
    })
}

var getDetails = function(id) {
    return new Promise((resolve,reject) => {
        server.get('/json/list.json').then(res => {
            var list = res.data.result
            list.forEach(item => {
                if(item._id == id){
                    resolve(item)
                    return 
                }
            });
            



        })
    })
}



export {
    getNav,
    getlist,
    getDetails,
}